package com.x;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import com.alibaba.fastjson.JSONObject;
import com.x.utils.MD5Util;
import com.x.utils.http.HttpUtil;

import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

/**
 * <p>
 * Description:
 * </p>
 * 
 * @Author Chenkangming
 * @Date 2015年11月9日
 * @version 1.0
 */
public class JoddTest1 {
	
	public void liangtian() {
		Map<String, Object> formMap = new HashMap<>();
		formMap.put("channelId", "1195");
		formMap.put("fee", "1");
		formMap.put("ip", "183.61.125.4");
		formMap.put("extra", "test,test1");
		formMap.put("imsi", "460000712629689");
		formMap.put("gameName", HttpUtil.UrlEncoder("钻石农场"));
		formMap.put("chargeName", "point");
		// 大写MD5值

		String mac = MD5Util.getMD5("1195" + "1" + "183.61.125.4" + "test,test1" + HttpUtil.UrlEncoder("钻石农场") + HttpUtil.UrlEncoder("point") + "6113td9j").toUpperCase();
		formMap.put("mac", mac);

		HttpResponse response = HttpRequest.post("http://121.41.58.237:8981/center/getCommand.sys").form(formMap).send();
		// 打印出请求参数
		System.out.println(response.getHttpRequest());

		System.out.println("=====================");
		// 打印出响应参数
		System.out.println(response);
	}

	@Test
	public void jianyi() {
		JSONObject json = new JSONObject();
		json.put("operation", "2");
		json.put("version", "1.0.0");
		JSONObject req = new JSONObject();
		req.put("appId", "1067");
		req.put("orderId", "");
		req.put("money", "100");
		req.put("imsi", "460030423861007");
		req.put("ipAddr", "183.61.125.4");
		req.put("area", "");
		req.put("ua", "XiaoMi");
		req.put("extData", "test,test1");
		req.put("feeName", "test1");
		json.put("reqChannel", req);

		HttpResponse response = HttpRequest.post("http://sms.ejamad.com/interfaceAction").body(json.toJSONString()).send();

		System.out.println(response.getHttpRequest());
		System.out.println(response.charset("UTF-8").bodyText());
	}
}
